package com.kevin.serial;

import com.alibaba.fastjson.JSON;
import com.kevin.constant.SerialType;

public class JsonSerializer  implements ISerializer{
    @Override
    public byte getSerialType() {
        return SerialType.SERIAL_JSON.getSerialType();
    }

    @Override
    public byte[] serialize(Object t) {

        return JSON.toJSONString(t).getBytes();
    }

    @Override
    public <T> T deSerialize(byte[] obj, Class<T> clazz) {
        return JSON.parseObject(new String(obj), clazz);
    }
}
